package com.ytsky.quotesystem.service.impl;

import com.ytsky.quotesystem.dao.CommentMapper;
import com.ytsky.quotesystem.entity.Comment;
import com.ytsky.quotesystem.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    /**
     * 添加用户评论
     *
     * @param comment
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean append(Comment comment) {
        return commentMapper.insert(comment) > 0;
    }

    /**
     * 删除用户评论
     *
     * @param id
     * @return
     */
    @Override
    public boolean remove(int id) {
        return commentMapper.remove(id) > 0;
    }
}
